<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <style>
        .light {
            background-color: #fff;
            color: black;
        }

        .dark {
            background-color: black;
            color: #fff;
        } 
    </style>

    <div class="light" style="height: 500px;">这是一段话</div>
    <button>夜间模式</button>

    <script>
        let div = document.querySelector('div');
        let button = document.querySelector('button');
        button.onclick = function() {
            if(div.className == 'light') {
                div.className = 'dark';
                button.innerHTML = '白天模式';
            }else if(div.className == 'dark') {
                div.className = 'light';
                button.innerHTML = '夜间模式';
            }
        }
    </script>
</body>
</html>